package com.qxzn.module.home.activity;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.qxzn.app.api.api.HttpRequest;
import com.qxzn.app.bean.ContactBean;
import com.qxzn.app.page.BaseActivity;
import com.qxzn.app.page.view.CustomItemView;
import com.qxzn.app.util.Constant;
import com.qxzn.app.util.DisplayUtil;
import com.qxzn.app.util.SharePreferenceUtil;
import com.qxzn.module.home.R;
import com.qxzn.module.home.R2;

import butterknife.BindView;
import butterknife.OnClick;

public class CareRemindDetailActivity extends BaseActivity {
    @BindView(R2.id.iv_head)
    ImageView ivHead;
    @BindView(R2.id.tv_name)
    TextView tvName;
    @BindView(R2.id.civ_voice_record)
    CustomItemView civVoiceRecord;
    @BindView(R2.id.view1)
    View view1;
    private ContactBean bean;
    private String username;

    @Override
    protected int initLayout() {
        return R.layout.activity_care_remind_detail;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void iniTitleBar() {
        tv_title.setText("关怀提醒数据");
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        bean = (ContactBean) getIntent().getSerializableExtra("bean");
        if (bean != null && bean.getUserresult() != null) {
            username = bean.getUsername();
            Glide.with(this).load(HttpRequest.BASE_URL + bean.getUserresult().getHeadportrait()).apply(new RequestOptions().placeholder(R.mipmap.icon_xiaopai_large).error(R.mipmap.icon_xiaopai_large)
                    .transforms(new CenterCrop(), new RoundedCorners(DisplayUtil.dip2px(this, 10)))).into(ivHead);
            tvName.setText(bean.getUserresult().getNiname());
            if (!TextUtils.equals(username, SharePreferenceUtil.getUserName(this))) {
                civVoiceRecord.setVisibility(View.VISIBLE);
                view1.setVisibility(View.VISIBLE);
            }
        }
    }

    @OnClick({R2.id.civ_voice_record, R2.id.civ_remind_record})
    public void onViewClicked(View view) {
        int i = view.getId();
        if (i == R.id.civ_voice_record) {
            startActivity(new Intent().setComponent(new ComponentName(this, "com.qxzn.module.im.activity.ChatActivity")).putExtra("receiver", username));
        } else if (i == R.id.civ_remind_record) {
            startActivity(new Intent(this, UserRemindListActivity.class).putExtra(Constant.PutExtraKey.USERNAME, username));
        }
    }

}
